//// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//package com.linqingying.gitcode.pullrequest
//
//import com.intellij.ide.actions.SplitAction
//import com.intellij.openapi.components.service
//import com.intellij.openapi.project.Project
//import com.linqingying.gitcode.api.GCRepositoryCoordinates
//import com.linqingying.gitcode.api.data.pullrequest.GCPullRequestShort
//import com.linqingying.gitcode.pullrequest.data.GCPRIdentifier
//import com.linqingying.gitcode.pullrequest.ui.toolwindow.model.GCPRToolWindowProjectViewModel
//import com.linqingying.gitcode.pullrequest.ui.toolwindow.model.GCPRToolWindowViewModel
//import com.linqingying.gitcode.ui.util.GCUIUtil
//import javax.swing.Icon
//
//@Suppress("EqualsOrHashCode")
//internal class GCPRTimelineVirtualFile(fileManagerId: String,
//                                       project: Project,
//                                       repository: GCRepositoryCoordinates,
//                                       pullRequest: GCPRIdentifier)
//  : GCPRVirtualFile(fileManagerId, project, repository, pullRequest) {
//
//  init {
//    putUserData(SplitAction.FORBID_TAB_SPLIT, true)
//    isWritable = false
//  }
//
//  override fun getName() = "#${pullRequest.number}"
//  override fun getPresentableName() = findDetails()?.let { "${it.title} $name" } ?: name
//
//  override fun getPath(): String = (fileSystem as GCPRVirtualFileSystem).getPath(sessionId, project, repository, pullRequest, false)
//  override fun getPresentablePath() = findDetails()?.url ?: "${repository.toUrl()}/pulls/${pullRequest.number}"
//
//  fun getIcon(): Icon? = findDetails()?.let { GCUIUtil.getPullRequestStateIcon(it.state, it.isDraft) }
//
//  override fun isValid(): Boolean = findProjectVm() != null
//
//  override fun setValid(valid: Boolean) = Unit
//
//  fun findProjectVm(): GCPRToolWindowProjectViewModel? =
//    project.service<GCPRToolWindowViewModel>().projectVm.value?.takeIf { it.repository == repository }
//
//  private fun findDetails(): GCPullRequestShort? = findProjectVm()?.findDetails(pullRequest)
//
//  override fun equals(other: Any?): Boolean {
//    if (this === other) return true
//    if (other !is GCPRTimelineVirtualFile) return false
//    return super.equals(other)
//  }
//}
